package com.fanpan26.jls.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @author fanpan26
 * @description JdkSpiApplication
 */
public class JdkSpiApplication {

    public static void main(String[] args) {

        ServiceLoader<Human> humans = ServiceLoader.load(Human.class);

        Iterator<Human> iterator = humans.iterator();
        while(iterator.hasNext()) {
            Human human = iterator.next();
            human.sayHello();
        }

        for (Human human : humans) {
            System.out.println(human.sayHello());
        }
    }
}
